var HOTELFunc = {
		instanceName : 'HOTELFunc'
		, ids : {
			wrap : 'div#wrap'
			, tabPromotion : '#promotion_tab'
			, f_adult : '#f_adult'
			, f_child : '#f_child'
			, f_starRating : '#f_starRating'
			, f_currency : '#f_currency'
			, f_place : '#f_place'
			, f_within : '#f_within'
			, f_availableOnly : '#f_availableOnly'
			, SS_CHANNEL : '#SS_CHANNEL'
			, SS_CURRENCY_CODE : '#SS_CURRENCY_CODE'
			, f_hotelName : '#f_hotelName'
			, f_arrDate : '#f_arrDate'
			, f_depDate : '#f_depDate'
			, btn_details : '.btn_detail_set'
			, btnPromotionFind : '#btn_findPromotion'
			, boxPromotionNodata : 'tplPmListNodata'
			, tplHotelList : 'tplHotelList'
			, hotelBox : '#content'
				
		}
		,searchHotel:function(){
			cfn_ajax({
				 url : '/biz/proc/searchHotelList.do'
				, data : $.param({//CRSFunc.getParam({
					SS_CHANNEL : $(HOTELFunc.ids.SS_CHANNEL).val()
					, company_id : 'HANATOUR'
					, SS_SVC_LANG_CODE : $(HOTELFunc.ids.SS_SVC_LANG_CODE).val()
					, f_hotelName : $(HOTELFunc.ids.f_hotelName).val()
					, f_arrDate : $(HOTELFunc.ids.f_arrDate).val()
					, f_depDate : $(HOTELFunc.ids.f_depDate).val()
				}) 
				, success : function(jsonData){
					var _tmpl = TrimPath.processDOMTemplate(HOTELFunc.ids.tplHotelList, jsonData.rows.OutValues[2].Value);
					$(HOTELFunc.ids.hotelBox).html(_tmpl).show(500);						
				}
			});			
		}
		, $gallery : function(){
			var onMouseOutOpacity = 0.4;
			$('#thumbs_room ul.thumbs li').opacityrollover({
				mouseOutOpacity:   onMouseOutOpacity,
				mouseOverOpacity:  1.0,
				fadeSpeed:         'fast',
				exemptionSelector: '.selected'
			});
			
			var gallery = $('#thumbs_room').galleriffic({
				delay:                     2500,
				numThumbs:                 100,
				preloadAhead:              10,
				enableTopPager:            false,
				enableBottomPager:         false,
				maxPagesToShow:            7,
				imageContainerSel:         '#slideshow_room',
				controlsContainerSel:      '#controls_room',
				captionContainerSel:       '#caption_room',
				loadingContainerSel:       '#loading_room',
				renderSSControls:          false,
				renderNavControls:         true,
				playLinkText:              'Play Slideshow',
				pauseLinkText:             'Pause Slideshow',
				prevLinkText:              '&lsaquo; Previous Photo',
				nextLinkText:              'Next Photo &rsaquo;',
				nextPageLinkText:          'Next &rsaquo;',
				prevPageLinkText:          '&lsaquo; Prev',
				enableHistory:             false,
				autoStart:                 false,
				syncTransitions:           true,
				defaultTransitionDuration: 900,
				onSlideChange:             function(prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of $('#thumbs')
					this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 1.0);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn:        function() {
					this.fadeTo('fast', 1.0);
				}
			});	
			
			$('#thumbs_hotel ul.thumbs li').opacityrollover({
				mouseOutOpacity:   onMouseOutOpacity,
				mouseOverOpacity:  1.0,
				fadeSpeed:         'fast',
				exemptionSelector: '.selected'
			});
			
			var gallery1 = $('#thumbs_hotel').galleriffic({
				delay:                     2500,
				numThumbs:                 100,
				preloadAhead:              10,
				enableTopPager:            false,
				enableBottomPager:         false,
				maxPagesToShow:            7,
				imageContainerSel:         '#slideshow_hotel',
				controlsContainerSel:      '#controls_hotel',
				captionContainerSel:       '#caption_hotel',
				loadingContainerSel:       '#loading_hotel',
				renderSSControls:          false,
				renderNavControls:         true,
				playLinkText:              'Play Slideshow',
				pauseLinkText:             'Pause Slideshow',
				prevLinkText:              '&lsaquo; Previous Photo',
				nextLinkText:              'Next Photo &rsaquo;',
				nextPageLinkText:          'Next &rsaquo;',
				prevPageLinkText:          '&lsaquo; Prev',
				enableHistory:             false,
				autoStart:                 false,
				syncTransitions:           true,
				defaultTransitionDuration: 900,
				onSlideChange:             function(prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of $('#thumbs')
					this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 1.0);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn:        function() {
					this.fadeTo('fast', 1.0);
				}
			});			
		}
		
		// -------------------- Function --------------------
		// initialize
		, initialize : function(){
			var thisFunc = window[this.instanceName];
			$(this.ids.wrap)
			.on('click', this.ids.btn_details, function(e){
				//Hotel Gallery Button click
				e.preventDefault();				
				CRSFunc
					.ajaxPop({
						 url : '/biz/proc/HotelGallery.do'
						, params : $.param({//CRSFunc.getParam({
							m : 'pop'
							, f_imgQty : 10
						})
						, callback : thisFunc.$gallery					
					});
			})	
			.on('click', this.ids.btnPromotionFind, function(e){
				//Hotel Gallery Button click
				e.preventDefault();							
				cfn_ajax({
					 url : '/biz/proc/selectPromotionList.do'
					, data : $.param({//CRSFunc.getParam({
						SS_CHANNEL : thisFunc.ids.SS_CHANNEL.val()
						, company_id : 'HANATOUR'
						, SS_SVC_LANG_CODE : thisFunc.ids.SS_SVC_LANG_CODE.val()
						, f_hotelName : $(rsvnFunc.ids.f_hotelName).val()
						, f_arrDate : $(rsvnFunc.ids.f_arrDate).val()
						, f_depDate : $(rsvnFunc.ids.f_depDate).val()
					}) 
					, success : function(jsonData){
						var _tmpl = TrimPath.processDOMTemplate(thisFunc.ids.tplHotelList, jsonData.rows.OutValues[2].Value);
						$(thisFunc.ids.hotelBox).html(_tmpl).show(500);						
					}
				});
			});				

			$(this.ids.f_adult).kendoDropDownList();
			$(this.ids.f_child).kendoDropDownList();
			$(this.ids.f_starRating).kendoDropDownList();
			$(this.ids.f_currency).kendoDropDownList();
			$(this.ids.f_place).kendoDropDownList();
			$(this.ids.f_within).kendoDropDownList();
			$(this.ids.f_availableOnly).kendoDropDownList();
			//$(this.ids.btnPromotionFind).trigger('click');
			thisFunc.searchHotel();
		}	// End >> initialize()
};

!function($){
	HOTELFunc.initialize();
}(jQuery);